package com.galaxy.service.controller.system;

import com.baomidou.mybatisplus.plugins.Page;
import com.galaxy.commom.base.message.ResponseCode;
import com.galaxy.commom.base.message.ResponseResult;
import com.galaxy.service.dto.system.log.QueryLogDto;
import com.galaxy.service.entity.system.SysLog;
import com.galaxy.service.service.system.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志控制器
 * @author caijinbang
 * @date 2018/10/28 00:02
 */
@Api(tags = {"日志管理接口"})
@RestController
@RequestMapping(value = "/system/log")
public class LogController {

  @Autowired
  private SysLogService sysLogService;


  @GetMapping("/list")
  @ApiOperation(value = "分页获取所有日志列表")
  @ApiImplicitParam(paramType = "header",name = "Authorization",value = "身份认证Token",required = true)
  public ResponseResult<Page<SysLog>> list(@RequestBody QueryLogDto queryLogDto){
    Page<SysLog> logPage = sysLogService.list(queryLogDto);
    return ResponseResult.e(ResponseCode.OK,logPage);
  }

  @PostMapping("/remove")
  @ApiOperation("批量删除")
  @ApiImplicitParam(paramType = "header",name = "Authorization",value = "身份认证Token")
  public ResponseResult removeList(@RequestBody @ApiParam("ID集合") List<String> logList){
    sysLogService.remove(logList);
    return ResponseResult.e(ResponseCode.OK);
  }

}
